<%@ page language="java" import="java.sql.*" pageEncoding="utf-8"%>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<%@page import="org.edu.system.LogWriter" %>
<html>
<head>
<title>  </title>
</head>
<body>
	<%
	   String driverName = "com.mysql.jdbc.Driver";
	   String userName = "root";
	   String userPwd = "123456";
	   String dbName = "Sa";
	   String url1="jdbc:mysql://localhost:3306/"+dbName;
	   String url2="?user="+userName+"&password="+userPwd;
	   String url3="&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC";
	   String url =url1+url2+url3;
	   Connection conn = DBConnect.getCon();
	   String sql="update teacher set tc_phone=?,tc_identity=?,tc_location=? where tc_id=?";
	   PreparedStatement pstmt = conn.prepareStatement(sql);
	   request.setCharacterEncoding("utf-8");//设置字符编码，避免出现乱码
	   String tc_phone = request.getParameter("tc_phone");
	   String tc_identity = request.getParameter("tc_identity");
	   String tc_location = request.getParameter("tc_location");
	   String tc_id = request.getParameter("tc_id");
	   pstmt.setString(1,tc_phone);
	   pstmt.setString(2,tc_identity);
	   pstmt.setString(3,tc_location);
	   pstmt.setString(4,tc_id);
	   try{
		   int n = pstmt.executeUpdate();
		   if(n>=1){%>
		   修改成功!<br><a href='javascript:history.back(-1)''>返回</a>
		   <%
		   LogWriter.LogPrint("["+request.getRemoteAddr()+"] "+tc_id+" 成功修改个人信息！");
		   }
		   else{%>
		   修改失败!<%=n%><a href="javascript:history.go(-1);location.reload()">返回</a>
		   <%
		   LogWriter.LogPrint("["+request.getRemoteAddr()+"] "+tc_id+" 修改个人信息失败！");
		   }
		   }catch(Exception e){%>
		   修改过程出现异常错误!<br><a href="javascript:history.go(-1);location.reload()">返回</a>
		   <%=e.getMessage() %>
		   <%
		   }
	   if(pstmt!=null){}
	   if(conn!=null){}
	%>
</body>
</html>